<!DOCTYPE html>
<html>
{include file='public/header'}
<body>
{include file='public/x-nav'}
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item layui-form-text">
            <label for="desc" class="layui-form-label">
                后台登录 IP白名单:
            </label>
            <div class="layui-input-inline">
                <textarea placeholder="请输入内容" id="desc" name="content" class="layui-textarea" cols="50" rows="15">{$ip_list}</textarea>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">* 请注意格式：一行一个IP</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button class="layui-btn" lay-filter="add" lay-submit="">
                保存
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

        //监听提交
        form.on('submit(add)', function (data) {
            //发异步，把数据提交给php
            $.post("{:url('set_ip')}",data.field,function(response){
                if(response.code === 200){
                    layer.alert("增加成功", {icon: 6}, function () {
                        window.location.reload();
                        return false;
                    });
                }else{
                    layer.msg(response.msg, {icon:5});
                    return false;
                }
            },'json')
            return false;
        });

    });
</script>
</body>
</html>